<?php
/**
 * /depot/library/models/Object/User.php
 * @author qqinxl
 * 2008/03/24
 * 
 * @category  
 * @package  
 * @copyright  Copyright (c) {}
 */

class Object_User extends Object_Abstract {
	
	public function isAdmin() {
		return $this->isEqual ( 'identity', Object_User_Identity::ADMIN );
	}
	public function isUser() {
		return $this->isEqual ( 'identity', Object_User_Identity::USER );
	}
	
	public function isIdentity($type) {
		switch ( strtolower ( $type )) {
			case "admin" :
				$type = Object_User_Identity::ADMIN;
			break;
			case "user" :
				$type = Object_User_Identity::USER;
			break;			
		}		
		return $this->isEqual ( 'identity', $type );
	}
	
	private $_tags = null;
	private $_categories = null;
	private $_blogs = null;
	/**
	 * @return Object_User
	 */
	public function setTagInfo($tags = null){
		if(!empty($tags)){
			$this->_tags = $tags;
		}else{			
			$tt = Module_Impl_Tag_Select::getInstance();		
			$this->_tags = $tt->getByField('user_id',$this->id,array(),false);
		}
		return $this;
	}
	public function getTagInfo(){
		return $this->_tags;
	}
	/**
	 * @return Object_User
	 */
	public function setCategoryInfo($categories = null){
		if(!empty($categories)){
			$this->_categories = $categories;
		}else{
			$tt = Module_Impl_Category_Select::getInstance();		
			$this->_categories = $tt->getByField('user_id',$this->id,array(),false);
		}	
		return $this;
	}
	public function getCategoryInfo(){
		return $this->_categories;
	}
	/**
	 * @return Object_User
	 */
	public function setBlogInfo($blogs = null){
		if(!empty($blogs)){
			$this->_blogs = $blogs;
		}else{			
			$tt = Module_Impl_Blog_Select::getInstance();		
			$this->_blogs = $tt->getByField('user_id',$this->id,array(),false);
		}	
		return $this;	
	}
	
	public function getBlogInfo(){
		return $this->_blogs;
	}
	
	public function isEnable(){
		return true;
	}
	
}